package com.atguigu.gulimail.product.entity;

import com.atguigu.common.group.AddGroup;
import com.atguigu.common.group.UpdateGroup;
import com.atguigu.common.group.UpdateStatusGroup;
import com.atguigu.common.selfValidator.ListVals;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 *
 * @author songshaoqiu
 * @email songshaoqiu@gmail.com
 * @date 2022-01-07 15:06:03
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 品牌id
     */
    @NotNull(groups = {UpdateGroup.class})  //意思就是在修改的时候，id不能为空。
    @Null(groups = {AddGroup.class})    //意思就是 在新增的时候，id为空。因为brandId是自增的。不能添加BrandId
    @TableId
    private Long brandId;
    /**
     * 品牌名
     */
    @NotEmpty(message = "品牌名不能一定要添加", groups = {UpdateGroup.class, AddGroup.class})    //这个意思就是 在新增和修改的时候，品牌名一定要有
    private String name;
    /**
     * 品牌logo地址
     */
    @NotNull(groups = {AddGroup.class}) //新增的时候，Logo必须不为null
    @URL(message = "url地址必须合法", groups = {UpdateGroup.class, AddGroup.class}) //新增和修改的时候。url必须合法
    private String logo;
    /**
     * 介绍
     */
    private String descript;
    /**
     * 显示状态[0-不显示；1-显示]
     */
    //自定义一个校验器
    @ListVals(vals = {0, 1}, groups = {UpdateStatusGroup.class, UpdateGroup.class})
    private Integer showStatus;
    /**
     * 检索首字母
     */
    @NotEmpty(groups = {AddGroup.class})
    @Pattern(regexp = "^[a-zA-Z]$", message = "请输入a-zA-Z", groups = {UpdateGroup.class, AddGroup.class})
    private String firstLetter;
    /**
     * 排序
     */
    @NotNull(groups = {AddGroup.class})
    @Min(value = 1, message = "输入的数值必须大于等于1", groups = {UpdateGroup.class, AddGroup.class})
    private Integer sort;

}
